<?php

declare (strict_types=1);
/*
 * This file is part of Leonsw.
 *
 * @link     https://leonsw.com
 * @document https://docs.leonsw.com
 * @contact  leonsw.com@gmail.com
 * @license  https://leonsw.com/LICENSE
 */
namespace App\Models\MainDB\BlindBox;

use Illuminate\Database\Eloquent\Model;
/**
 * @property int $id 
 * @property int $level
 * @property int $exp
 * @property int $count
 * @property int $input 
 * @property int $output 
 * @property int $balance 
 * @property int $total_balance 
 * @property \Carbon\Carbon $created_at 
 * @property \Carbon\Carbon $updated_at 
 */
class User extends Model
{
    protected $table = 'ln_blind_box_user';
    // protected $fillable = [];
    protected $guarded = [];
    protected $casts = ['id' => 'int', 'balance' => 'integer', 'total_balance' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

    public function getDateFormat()
    {
        return 'Y-m-d H:i:s.u';
    }

    public function info()
    {
        return $this->hasOne(\App\Models\MainDB\User::class, 'user_id', 'id');
    }

    public function user_data()
    {
        return $this->hasOne('App\Models\MainDB\UserData', 'user_id', 'id');
    }

    public function week()
    {
        return $this->hasOne(UserStatWeek::class, 'user_id', 'id')->withDefault([
            'count' => 0,
            'input' => 0,
            'output' => 0,
        ]);
    }

    public function date()
    {
        return $this->hasOne(UserStatDate::class, 'user_id', 'id')->withDefault([
            'count' => 0,
            'input' => 0,
            'output' => 0,
        ]);
    }


}